package com.example.jetpacktest.viewmodel

import android.view.View
import android.widget.Toast
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.example.jetpacktest.domain.User

class Test1ViewModel: ViewModel() {

    val user: MutableLiveData<User> = MutableLiveData<User>()

    fun getInitUser(){
        user.value = User("hello", "666")
    }

    private fun getUserFromNet(){
        user.value = User("张三", "123456")
    }

    /**
     * 按钮一的点击事件
     */
    fun onBtn1Click(v: View){
        //Toast.makeText(v.context, "点击了按钮一", Toast.LENGTH_SHORT).show()
        getUserFromNet()
    }

}